home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
bsrc_p1.arc
/
BTCONFIG.C
< prev
next >
Wrap
Text File
|
1988-11-29
|
12KB
|
412 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software <no-Inc> */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / No-Cost<no-tm> Software. */
/* \ 1011 / */
/* ------ KopyRong (K) 1987. ALL RIGHTS REVERSED. */
/* */
/* */
/* This module was written by Vince Perriello */
/* */
/* */
/* BinkleyTerm Configuration File Parser */
/* */
/* */
/* This software package is being distributed WITH FULL SOURCE CODE */
/* with the following conditions: 1) If anything awful happens */
/* because you use it (or don't use it), you accept full */
/* responsibility; 2) you don't start making tons of voice calls to */
/* the authors to complain or make suggestions about enhancements, */
/* useful or otherwise; 3) you do not reuse this code in commercial */
/* products without specific permission to do so from the authors; */
/* 4) If you find any problems you send fixes to the authors for */
/* inclusion in updates; 5) You find some way to express your */
/* appreciation for this method of distribution, either by writing */
/* code or application notes, or just sending along a "Thank You" */
/* message. */
/* */
/* There is copyrighted code in this product. We either wrote it */
/* ourselves or got permission to use it. Please don't force us to */
/* pay a lawyer -- have some respect for our motives and don't abuse */
/* this "license". */
/* */
/* */
/*--------------------------------------------------------------------------*/
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <conio.h>
#include "com.h"
#include "xfer.h"
extern int port_ptr; /* and the port spec */
extern struct pointers ctl; /* where the CD mask is */
extern char boss_net,boss_node; /* host node number in list */
extern char no_pickup;
extern char no_requests;
extern int n_requests;
extern int baud;
extern int lock_baud;
extern int un_attended;
extern int small_window;
extern int no_overdrive;
extern int fullscreen;
extern int autobaud;
extern int command_line_un;
extern int overwrite;
extern int loglevel;
extern int slowmodem;
extern int BBStimeout;
extern char *BBSopt; /* BBS option */
extern char *BBSbanner; /* Banner to show if called */
extern char *BBSreader; /* Message reader to invoke */
extern char *BOSSphone; /* Boss phone number */
extern char *BINKpath;
FILE *status_log = NULL;
int num_addrs = 1;
parse_config()
{
FILE *stream;
char temp[256];
char *c, *ctl_string();
char *skip_blanks();
char *config_file = "Binkley.Cfg";
int i;
sprintf (temp, "%s%s", BINKpath, config_file);
if ((stream = fopen(temp,"r")) == NULL) /* OK, let's open the file */
return(0); /* no file, no work to do */
while((fgets(temp,255,stream)) != NULL) /* Now we parse the file ... */
{
c = temp; /* Check out the first char */
if ((*c == '%') || (*c == ';')) /* See if it's a comment line*/
continue;
i = strlen(temp); /* how long this line is */
if (i < 3)
continue;
c = &temp[--i]; /* point at last character */
if (*c == '\n') /* if it's a newline, */
*c = '\0'; /* strip it off */
if (strnicmp(temp,"overwrite",9) == 0) /* Overwrite existing files */
{
overwrite = 1;
continue;
}
if (strnicmp(temp,"lockbaud",8) == 0) /* Keep baud rate always locked */
{
lock_baud = 1;
continue;
}
if (strnicmp(temp,"event",5) == 0) /* Events to be executed */
{
c = skip_blanks(&temp[5]);
parse_event (c);
continue;
}
if (strnicmp(temp,"zone",4) == 0) /* Zone we are in */
{
c = skip_blanks(&temp[4]);
ctl.our_zone = atoi(c);
if (!ctl.our_zone) /* if we didn't find a zone */
printf("Illegal zone: %s\n", &temp[4]);
continue;
}
if (strnicmp(temp,"timeout",7) == 0) /* How long before timeout to BBS */
{
c = skip_blanks(&temp[7]);
BBStimeout = atoi(c) * 100;
continue;
}
if (strnicmp(temp,"maxreq",6) == 0) /* Maximum number of requests */
{
c = skip_blanks(&temp[6]);
n_requests = atoi(c);
if (!n_requests) /* No requests??? */
printf ("0 requests allowed\n");
continue;
}
if (strnicmp(temp,"noslo",5) == 0) /* No SLO stuff */
{
no_overdrive = 1;
continue;
}
if (strnicmp(temp,"slowmodem",9) == 0) /* Modem reacts slowly */
{
slowmodem = 1;
continue;
}
if (strnicmp(temp,"smallwindow",11) == 0) /* Small SEAlink windows */
{
small_window = 1;
continue;
}
if (strnicmp(temp,"nopickup",8) == 0) /* No FTSC pickup */
{
no_pickup = 1;
continue;
}
if (strnicmp(temp,"norequests",10) == 0) /* No SEAdog file requests */
{
no_requests = 1;
continue;
}
if (strnicmp(temp,"loglevel",8) == 0) /* Level of logging to do */
{
c = skip_blanks(&temp[8]);
i = atoi(c);
if ((i <= 5) && (i > 0))
{
loglevel = i;
}
else
{
printf ("LogLevel must be 1-5 - %s is unknown\n", &temp[8]);
}
continue;
}
if (strnicmp(temp,"baud",4) == 0) /* if this is a BAUD rate */
{
ctl.max_baud = atoi (&temp[4]);
continue;
}
if (strnicmp(temp,"port",4) == 0) /* if this is a PORT spec */
{
c = skip_blanks(&temp[4]);
i = atoi(c); /* make it binary */
if ((i == 1) || (i == 2)) /* see if it's OK */
port_ptr = i - 1; /* store it if so */
else
printf("Illegal port: %s\n",&temp[4]);
continue;
}
if (strnicmp(temp,"carrier",7) == 0) /* if this is a CARRIER spec */
{
c = skip_blanks(&temp[7]);
i = 0;
sscanf(c,"%x",&i); /* convert it to binary */
if (i != 0) /* if we got anything */
ctl.carrier_mask = i;
else
printf("Invalid CARRIER mask: %s\n",&temp[7]);
continue;
}
if (strnicmp(temp,"statuslog",9) == 0) /* Log file for status messages */
{
ctl.log_name = ctl_string(&temp[9]);
if ((status_log = fopen (ctl.log_name, "aa")) == NULL)
{
free (ctl.log_name);
ctl.log_name = NULL;
}
else
{
fprintf (status_log, "\n");
real_flush (fileno (status_log));
}
continue;
}
if (strnicmp(temp,"reader",6) == 0) /* Message reader to invoke (Alt-M) */
{
BBSreader = ctl_string (&temp[6]);
continue;
}
if (strnicmp(temp,"bossphone",9) == 0) /* Boss's phone number */
{
BOSSphone = ctl_string (&temp[9]);
continue;
}
if (strnicmp(temp,"system",6) == 0) /* if this is system name */
{
ctl.system_name = ctl_string(&temp[6]);
continue;
}
if (strnicmp(temp,"sysop",5) == 0) /* if this is my name */
{
ctl.sysop = ctl_string(&temp[5]);
continue;
}
if (strnicmp(temp,"boss",4) == 0) /* if this is my boss name */
{
c = skip_blanks(&temp[4]);
sscanf(c,"%d/%d",&boss_net,&boss_node);
continue;
}
if (strnicmp(temp,"point",5) == 0) /* if this is my point name */
{
c = skip_blanks(&temp[5]);
sscanf(c,"%d/%d",&ctl.alias[0].net,&ctl.alias[0].node);
continue;
}
if (strnicmp(temp,"aka",3) == 0) /* if this is an aka for me */
{
c = skip_blanks(&temp[3]);
sscanf(c,"%d/%d",&ctl.alias[num_addrs].net,&ctl.alias[num_addrs].node);
++num_addrs;
continue;
}
if (strnicmp(temp,"hold",4) == 0) /* matrix hold area */
{
ctl.hold_area = ctl_string(&temp[4]);
continue;
}
if (strnicmp(temp,"netfile",7) == 0) /* inbound file area */
{
ctl.filepath = ctl_string(&temp[7]);
continue;
}
if (strnicmp(temp,"netmail",7) == 0) /* matrix message area */
{
continue; /* for BTCTL & MAIL.SYS */
}
if (strnicmp(temp,"init",4) == 0) /* Modem init string */
{
ctl.m_init = ctl_string(&temp[4]);
continue;
}
if (strnicmp(temp,"busy",4) == 0) /* Modem busy string */
{
ctl.m_busy = ctl_string(&temp[4]);
continue;
}
if (strnicmp(temp,"prefix",6) == 0) /* if this is the dial prefix*/
{
ctl.predial = ctl_string(&temp[6]);
continue;
}
if (strnicmp(temp,"suffix",6) == 0) /* if this is the dial suffix*/
{
ctl.postdial = ctl_string(&temp[6]);
continue;
}
if (strnicmp(temp,"nodelist",8) == 0) /* if a nodelist spec, */
{
ctl.net_info = ctl_string(&temp[8]);
continue;
}
if (strnicmp(temp,"avail",5) == 0) /* if "AVAIL" file, */
{
ctl.avail_list = ctl_string(&temp[5]);
continue;
}
if (strnicmp(temp,"okfile",6) == 0) /* if F/R candidate list, */
{
ctl.request_list = ctl_string(&temp[6]);
continue;
}
if (strnicmp(temp,"about",5) == 0) /* if "ABOUT" file, */
{
ctl.freq_about = ctl_string(&temp[5]);
continue;
}
if (strnicmp(temp,"bbs",3) == 0) /* if "BBS" line, */
{
BBSopt = ctl_string(&temp[3]);
continue;
}
if (strnicmp(temp,"banner",6) == 0) /* if "BANNER" line, */
{
BBSbanner = ctl_string(&temp[6]);
continue;
}
if (strnicmp(temp,"unattended",10) == 0) /* if unattended mode */
{
un_attended = 1;
command_line_un = 1;
continue;
}
if (strnicmp(temp,"nofullscreen",12) == 0) /* Full screen mode off */
{
fullscreen = 0;
continue;
}
if (strnicmp(temp,"autobaud",8) == 0) /* Use highest baud when dialing */
{
autobaud = 1;
continue;
}
printf("Unknown config line: %s\n",temp);
}
fclose(stream); /* close input file */
if (ctl.m_init == NULL)
{
ctl.m_init = ctl_string ("|AT|");
}
if (ctl.m_busy == NULL)
{
ctl.m_busy = ctl_string ("|AT|");
}
}
char *ctl_string(source) /* malloc & copy to ctl */
char *source;
{
char *malloc();
char *dest, *c;
c = skip_blanks(source); /* get over the blanks */
dest = malloc(strlen(c)+1); /* allocate space for string */
strcpy(dest,c); /* copy the stuff over */
return(dest); /* and return the address */
}
char *skip_blanks(string)
char *string;
{
while (*string && isspace (*string))
++string;
return(string);
}